package com.mapper;

import com.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from  user_chen")
    List<User> All();

    @Select(value = "select * from user_chen where username=#{account}")
    List<User> listAll();

    @Insert("INSERT INTO user_chen (username,password) values (#{username},#{password})")
    int insert(User user);

    @Select("SELECT * FROM `user_chen` WHERE (username=#{account} AND password = #{password}) or (phone =#{account} AND password = #{password}) ")
    List<User> login(@Param("account") String account,@Param("password")String password);

    @Update("UPDATE user_chen SET phone = #{phone}WHERE id =#{id};")
    int updatephone(User user);

    @Update("UPDATE user_chen SET password = #{password} WHERE id = #{id}")
    int updatePassword(User user);

    @Select("SELECT * FROM user_chen WHERE username LIKE concat ('%',#{username},'%')")
    List<User> search(User user);

    @Delete("delete  from user_chen where id =#{id}")
    Integer delete(@Param("id") Integer id);

    @Update("UPDATE user_chen SET username = #{username}, password = #{password}, nickname = #{nickname}, phone = #{phone}, point =#{point} WHERE id =#{id};")
    Integer update(User user);

    @Insert("insert into user_chen (username,password,nickname,phone,point) values (#{username},#{password},#{nickname},#{phone},#{point})")
    Integer tianjia(User user);
}
